<template>

  <div class="box">
    <div style="height:1.0667rem;"></div>

  <van-cell-group>
    <van-field v-model="value" placeholder="请输入用户名" />
  </van-cell-group>
  <van-button type="info" size='large' @click="add">添加商品</van-button>

  </div>
</template>
<script>
export default {
  data () {
    return {
      value: ''

    }
  },
  created () {
  },
  methods: {
    async add () {
      const { data: res } = await this.$http.post('http://www.liulongbin.top:3005/api/addproduct', `name=${this.value}`)
      console.log(res)
      if (this.value.trim().length <= 0) {
        this.$notify('请输入商品名称')
      } else {
        this.$notify({ type: 'success', message: '添加成功' })
      }
      this.$router.go(-1)
    },
    Back () {
      this.$router.go(-1)
    }
  }
}
</script>
<style lang="less">
.box{
  padding: 0 10px;

}
.van-button--large {
    height: 40px !important;
    background: #1989fa;
    border: 1px solid #1989fa;
    line-height: 38px !important;
    margin: 40px 0 !important;

}

</style>
